<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddIsLockToAdminUsersTable extends Migration
{
    /**
     * Run the migrations.
     *  用户表 扩展
     * @return void
     */
    public function up()
    {
        Schema::table('admin_users', function (Blueprint $table) {
            //
            $table->integer('mt_login')->unique()->nullable()->after('username')->comment('交易账户');
            $table->string('en_name')->nullable()->after('name')->comment('用户英文名');
            $table->integer('tjr_id')->default(0)->after('en_name')->comment('推荐人');
            $table->text('child')->nullable()->after('tjr_id')->comment('存放用户所有上级');
            $table->string('phone')->nullable()->after('child')->comment('手机号');
            $table->string('email')->nullable()->after('phone')->comment('邮箱号');
            $table->string('pay_password')->nullable()->after('email')->comment('支付密码');
            $table->text('dry_password')->nullable()->after('pay_password')->comment('其它密码');
            $table->string('profit_rate')->default(50)->after('pay_password')->comment('结算比例');
            $table->integer('is_auth')->nullable()->default(0)->after('profit_rate')->comment('是否认证资料');
            $table->string('sfz_zimg')->nullable()->after('is_auth')->comment('身份证正面');
            $table->string('sfz_fimg')->nullable()->after('sfz_zimg')->comment('身份证正面');
            $table->string('sfz_id')->nullable()->after('sfz_fimg')->comment('身份证号码');
            $table->string('address')->nullable()->after('sfz_id')->comment('住址');
            $table->string('bank_number')->nullable()->after('address')->comment('银行卡号');
            $table->string('bank_type')->nullable()->after('bank_number')->comment('开户银行');
            $table->string('bank_address')->nullable()->after('bank_type')->comment('开户支行');
            $table->string('swift_code')->nullable()->after('bank_address')->comment('外国银行编码');
            $table->string('is_lock')->default(1)->after('swift_code')->comment('是否锁定');
            $table->string('is_mail')->default(1)->after('is_lock')->comment('是否返佣');
            $table->string('is_withdrawal')->default(1)->after('is_mail')->comment('是否出金');
            $table->decimal('investment_amount',16,4)->default(0)->nullable()->after('is_withdrawal')->comment('投入数量');
            $table->decimal('trade_balance',16,4)->default(0)->nullable()->after('investment_amount')->comment('投资产品');
            $table->decimal('agent_balance',16,4)->default(0)->nullable()->after('trade_balance')->comment('下级产品');
            $table->string('users_leader_id')->default(0)->comment('用户等级');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('admin_users', function (Blueprint $table) {
            $table->dropColumn('mt_login');
            $table->dropColumn('en_name');
            $table->dropColumn('tjr_id');
            $table->dropColumn('child');
            $table->dropColumn('phone');
            $table->dropColumn('email');
            $table->dropColumn('pay_password');
            $table->dropColumn('dry_password');
            $table->dropColumn('profit_rate');
            $table->dropColumn('is_auth');
            $table->dropColumn('sfz_zimg');
            $table->dropColumn('sfz_fimg');
            $table->dropColumn('sfz_id');
            $table->dropColumn('bank_number');
            $table->dropColumn('bank_type');
            $table->dropColumn('bank_address');
            $table->dropColumn('address');
            $table->dropColumn('swift_code');
            $table->dropColumn('is_lock');
            $table->dropColumn('is_mail');
            $table->dropColumn('is_withdrawal');
            $table->dropColumn('investment_amount');
            $table->dropColumn('trade_balance');
            $table->dropColumn('agent_balance');
        });
    }
}
